package overload;

/**
 * @Author Stringzhua
 * @Date 2024/2/29 11:05
 * description:可变参数练习题
 * 有三个方法,分别实现:
 * 返回姓名和两门课成绩(总分)
 * 返回姓名和三门课成绩(总分)
 * 返回姓名和五门课成绩(总分)
 */
public class varparameterexercise {
    public static void main(String[] args) {
        sumMethod03 m = new sumMethod03();
        System.out.println(m.f1("milan",90.0,10.0));
        System.out.println(m.f1("zhuazhua",90.0,10.0,10.0));
        System.out.println(m.f1("zjy",90.0,10.0,20.0,30.0,50.0));
    }
}
class sumMethod03{
    public String f1(String name, double... score){
        System.out.println("传入的字符串长度为"+name.length()+" "+score.length);
        double sum=0;
        for (int i = 0; i < score.length; i++) {
            sum+=score[i];
        }
        return name+"有"+score.length+"门课的成绩总分为="+sum;
    }
}
